/*
 * @Description:
 * @Author: py
 * @Date: 2024-08-07
 */
import type { OptionsRow, OptionsType } from 'plus-pro-components'

export function useDicts() {
    const propertyType = {
        1: '住宅',
        2: '活力商业',
        3: '康养综合体',
        4: '酒店',
        5: '高端写字楼',
        6: '文化剧场',
    }

    const type = {
        1: '广告资讯【顶部】', // 顶部滚动可跳转
        2: 'banner', // 跳转
        3: '弹出框广告',
        // 4: '推荐有礼', // 小程序跳转
        4: '尊享会员权益', // 跳转
        5: '品牌介绍', // 跳转
        6: '云城家书', // 多列表显示
        7: '社群申请', // 跳转
        8: '健康服务', // 跳转
        9: '空间资源',
        10: '社群主理人招募',
        11: '主理人列表',
        12: '社群列表',

        ///
        ...Object.fromEntries(Object.entries(propertyType).map(i => ([+i[0] + 100, i[1]]))),
    }

    const linkType = {
        0: '不跳转',
        1: '跳转',
    }

    const dicts = {
        type,
        propertyType,
        linkType,
    }

    const getDictLabel = (mapKey: string, dicKey: number | string) => {
        if (mapKey in dicts) {
            return dicts[mapKey][dicKey]
        }
        else {
            return ''
        }
    }

    const getDictOptions: (mapKey: string) => OptionsRow[] = (mapKey: string) => {
        if (mapKey in dicts) {
            const targetMap = dicts[mapKey]
            const dictOptions = Object.entries(targetMap).map(([key, val]) => ({
                label: val,
                value: +key,
            }))
            return dictOptions as OptionsRow[]
        }
        else {
            return []
        }
    }

    return { getDictLabel, getDictOptions }
}
